import { allElFormItemsOptions, loadComOptions } from "@/utils/loadComOptions";

const getElCom = new allElFormItemsOptions(),
  getElComOption = new loadComOptions(),
  defaultColum = (): Array<elComAttrAndFunType[]> => [
    [
      getElCom.getInput(
        {
          span: 6
        },
        {
          label: "搜索字典值",
          prop: "label"
        }
      ),
      getElCom.getSelect(
        {
          span: 6,
          dict: "dict_list",
          clearable: false
        },
        {
          label: "切换字典类型",
          prop: "dict"
        }
      ),
      {
        formItem: {
          prop: "btn"
        },
        slot: "operation",
        span: 12
      }
    ]
  ],
  dialogColums = (): Array<elComAttrAndFunType[]> => [
    [
      getElCom.getInput(
        {
          span: 24,
          disabled: true
        },
        {
          required: true,
          label: "字典类型",
          prop: "dictType"
        }
      )
    ],
    [
      getElCom.getSelect(
        {
          span: 24,
          dict: "el_tag_type"
        },
        {
          required: true,
          label: "字典类型标签",
          prop: "description"
        }
      )
    ],
    [
      getElCom.getInput(
        {
          span: 24
        },
        {
          required: true,
          label: "字典值",
          prop: "value"
        }
      )
    ],
    [
      getElCom.getInput(
        {
          span: 24
        },
        {
          required: true,
          label: "字典标签",
          prop: "label"
        }
      )
    ]
  ];
export default {
  form: getElComOption.getFormOptions({
    labelWidth: "90px"
  }),
  countInter: getElComOption.countInter(defaultColum()),
  dicts: getElComOption.countDict(defaultColum()),
  columns: defaultColum()
} as FyhComOptions;
export const Dialog: FyhComOptions = {
  form: getElComOption.getFormOptions({
    labelWidth: "100px"
  }),
  dicts: getElComOption.countDict(dialogColums()),
  columns: dialogColums(),
  rules: form =>
    getElComOption.createFormRules({
      dictType: {
        rule: ["blur", "请输入字典类型"]
      },
      value: {
        rule: ["blur", "请输入字典值"]
      },
      label: {
        rule: ["blur", "请输入字典标签"]
      },
      description: {
        rule: ["change", "请输入字典类型标签"]
      }
    })
};
